-
Notifications
You must be signed in to change notification settings - Fork 78
feature: integration test: in github workflow #396
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Signed-off-by: Nikita B <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello @n2h9, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!
Summary of Changes
This pull request introduces an integration test using a GitHub workflow. It adds a Makefile target for running integration tests, a docker-compose file to spin up a NATS server, and a Go test file with an integration test that verifies connectivity to the NATS server. The integration test checks if messages are received in NATS after the main application is started with the NATS broker URL set via an environment variable.
Highlights
- Integration Test Setup: Introduces a
docker-compose.yamlfile to define a NATS service for local integration testing. - Makefile Integration Test Target: Adds an
integration-testtarget to the Makefile to start NATS via docker-compose, run the integration tests, and then stop NATS. - NATS Connectivity Test: Creates a Go test (
main_test.go) that verifies the application can connect to the NATS server and receive messages.
Changelog
Click here to see the changelog
- Makefile
- Added
integration-testtarget to start NATS using docker-compose, run integration tests, and stop NATS. - The integration test requires a k8s cluster (with installed meshsync CRD) and nats streaming.
- Added
- docker-compose.yaml
- Created a docker-compose file to define a NATS service for local integration testing.
- Exposes NATS ports 4222 and 8222.
- go.mod
- Added
github.com/stretchr/testifyfor assertions in the integration test. - Added
github.com/pmezard/go-difflibas an indirect dependency.
- Added
- main_test.go
- Created a new test file
main_test.gocontaining theTestWithNatsIntegrationfunction. - The test verifies that the application can connect to the NATS server and receive messages.
- The test is skipped if the
RUN_INTEGRATION_TESTSenvironment variable is not set totrue.
- Created a new test file
Using Gemini Code Assist
The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.
Invoking Gemini
You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.
| Feature | Command | Description |
|---|---|---|
| Code Review | /gemini review |
Performs a code review for the current pull request in its current state. |
| Pull Request Summary | /gemini summary |
Provides a summary of the current pull request in its current state. |
| Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in issue comments and review comments. |
| Help | /gemini help |
Displays a list of available commands. |
Customization
To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.
Limitations & Feedback
Gemini Code Assist is currently in preview and may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments to provide feedback.
You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.
A test to integrate,
NATS streams, communicate,
Messages flow free,
Connectivity,
Success! We celebrate.
Footnotes
-
Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This PR introduces an integration test using a GitHub workflow. It includes changes to the Makefile, adds a docker-compose file for NATS, updates go.mod, and creates a new test file (main_test.go). The integration test checks if messages are received in NATS. Overall, the changes seem reasonable, but there are a few areas that could be improved.
Summary of Findings
- Missing Error Handling: The
integration-testtarget in the Makefile lacks error handling fordocker compose upanddocker compose down. This could lead to the test failing silently if these commands fail. - Hardcoded Sleep Duration: The
sleep 4command in the Makefile uses a hardcoded value. It would be better to use a variable or a more dynamic approach to ensure NATS is ready before running the tests. - TODO in Test: The
TestWithNatsIntegrationfunction inmain_test.gocontains aTODOcomment indicating that the check for received messages could be more meaningful.
Merge Readiness
The changes introduce a valuable integration test. However, the missing error handling in the Makefile and the TODO in the test function should be addressed before merging. I am unable to approve this pull request, and recommend that others review and approve this code before merging.
| ## docker compose exposes nats on default ports to host, so they must be available | ||
| integration-test: | ||
| docker compose up -d | ||
| sleep 4 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The sleep 4 command uses a hardcoded value. It would be better to use a variable or a more dynamic approach to ensure NATS is ready before running the tests. Consider using docker compose ps and checking the status of the NATS container.
# Example using a loop and docker compose ps (untested):
# ready=false
# until $ready; do
# status=$$(docker compose ps --services --filter "status=running" nats)
# if [[ "$${status}" == "nats" ]]; then
# ready=true
# else
# sleep 1
# fi
# done
sleep 4
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks gemi 🤗 , the idea is good, but the suggested snippet is not working.
I briefly tried to play a little with similar ideas, but didn't succeed 😄 , so sleep 4 is the best option for now 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a good comment from Gemini. While use of sleep() is almost never desired, replacement of its use can sometimes be more trouble than it's worth.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're welcome! I understand the challenges with dynamic checks in docker compose. While sleep 4 might be the most practical option for now, keep an eye on its reliability as the environment evolves. If the tests become flaky, revisiting the dynamic check might be necessary.
Signed-off-by: Nikita B <[email protected]>
Signed-off-by: Nikita B <[email protected]>
Signed-off-by: Nikita B <[email protected]>
Signed-off-by: Nikita B <[email protected]>
Signed-off-by: Nikita B <[email protected]>
Signed-off-by: Nikita B <[email protected]>
Signed-off-by: Nikita B <[email protected]>
Signed-off-by: Nikita B <[email protected]>
Signed-off-by: Nikita B <[email protected]>
Signed-off-by: Nikita B <[email protected]>
| pull_request: | ||
| branches: | ||
| - "master" | ||
| paths: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might make sense to invert this list with that of a list of files to ignore.
Signed-off-by: Lee Calcote <[email protected]>
|
resolved merged conflict in go.mod |
Signed-off-by: Lee Calcote <[email protected]>
…ot being checked. Signed-off-by: Lee Calcote <[email protected]>
Description
This PR implements integration test running in ci.
Infrastructure set up was copied from meshery: link.
Test flow is as follows:
main();TODO
Meshsync CI pipeline failure is fixed in a separate pr: #397
Signed commits